function AddContentANDScroll() {
   newsdiv = document.getElementById('news_scroll');
   commentsdiv = document.getElementById('member_comments_scroll');
   occupationsdiv = document.getElementById('occupations_scroll');
   gallerydiv = document.getElementById('member_gallery');
   tmofferdiv = document.getElementById('tmoffer');
   locationsdiv = document.getElementById('locations');
   if(newsdiv != null) {    // **************************** 1. TopMatch News:
     newsdiv.innerHTML = "<div>Teste de  Personalidade Dispon&iacute;vel!</div>" +
                         "<div>Galeria  de Membros (opcional) Dispon&iacute;vel!</div>" +
                         "<div>TopMatch  UK - Escrit&oacute;rio em Twickenham J&aacute; Abriu!</div>" +
                         "<div>TopMatch  UK - Escrit&oacute;rio em Redhill J&aacute; Abriu!</div>" +
                         "<div>TopMatch  Canad&aacute; - Escrit&oacute;rio em Abbotsford J&aacute; Abriu!</div>" +
                         "<div>TopMatch  UK - Escrit&oacute;rio em Lancashire J&aacute; Abriu!</div>" +
                         "<div>TopMatch  Canad&aacute; - Escrit&oacute;rio em Surrey J&aacute; Abriu!</div>" +
                         "<div>TopMatch  Canad&aacute; - Escrit&oacute;rio em Langley J&aacute; Abriu!</div>" +
                         "<div>Novo  Dating Blog Dispon&iacute;vel!</div>" +
                         "<div>Attraction  Guide GR&Aacute;TIS Dispon&iacute;vel!</div>" +
                         "<div>Nova  funcionalidade Live Chat Help Dispon&iacute;vel!</div>" +
                         "<div>Dating  Guide GR&Aacute;TIS Dispon&iacute;vel!</div>" +
                         "<div>TopMatch  UK - Escrit&oacute;rio em Leeds Abre em Breve!</div>" +
                         "<div>TopMatch  UK - Escrit&oacute;rio em Harrogate Abre em Breve!</div>" +
                         "<div>TopMatch  Portugal - Escrit&oacute;rio em Lisboa J&aacute; Abriu!</div>";
     var newsscroll = new scrollObject("news_scroll", 400, 16, "left", 1, 0.4);
     newsscroll.scroll();
   }
   if(commentsdiv != null) {   // **************************** 2. Member Comments:
     commentsdiv.innerHTML = "<div>\"... Ap&oacute;s 6 meses ainda est&aacute; tudo a correr muito bem, t&atilde;o  bem que ele veio viver comigo! Tamb&eacute;m estamos a fazer planos para o futuro e  ele tornou-se uma parte muito importante da minha vida presente. Obrigada por  ajudarem o nosso encontro! \"<span>Sr.&ordf; L - Fevereiro 2009.</span></div>" +
                             "<div>\"... Come&ccedil;&aacute;mos a viver juntos no fim de Agosto e estamos a ter  momentos maravilhosos juntos, ontem &agrave; noite ele pediu-me em casamento e, claro,  eu aceitei. Voc&ecirc;s estar&atilde;o no topo da lista do casamento e obrigada por nos  apresentarem, voc&ecirc;s mudaram as nossas vidas!\"<span>Sr.&ordf; R - Dezembro 2008.</span></div>" +
                             "<div>\"... O servi&ccedil;o tem sido excelente, bastou apenas 3 apresenta&ccedil;&otilde;es  para o encontrar, estamos muito felizes e queremos agradecer-vos por nos  ajudarem! ...\"<span> Sr.&ordf; O - Novembro 2008.</span></div>" +
                             "<div>\"... Como sabem nunca antes tinha usado um servi&ccedil;o de encontros  excepto os sites da internet, fizeram com que a minha inscri&ccedil;&atilde;o fosse muito  f&aacute;cil e puseram-me &agrave; vontade. H&aacute; 3 meses que estamos juntos e vai tudo muito  bem, recomendar-vos-&iacute;a a qualquer pessoa! ...\"<span> Sr. B - Setembro 2008.</span></div>" +
                             "<div>\"... Eu quero agradecer ao TopMatch por tornar os &uacute;ltimos sete  meses da minha vida t&atilde;o fant&aacute;sticos. Eu sinto-me como se tivesse de novo 21  anos! A vida &eacute; t&atilde;o boa que me apetece correr para o topo das colinas e gritar  para dizer a toda gente como a minha vida &eacute; maravilhosa! ...\"<span> Sr.&ordf; C - Julho  2008.</span></div>" +
                             "<div>\"... A minha parceira e eu quer&iacute;amos agradecer profundamente ao  TopMatch por nos juntar. Estamos a ter momentos maravilhosos e a planear cada  vez mais tempo juntos, incluindo feriados. Que servi&ccedil;o brilhante! ...\"<span> Sr. R -  Janeiro 2008.</span></div>" +
                             "<div>\"... Servi&ccedil;o Fant&aacute;stico! Que mais podemos dizer. Foi uma  experi&ecirc;ncia aterradora ao princ&iacute;pio visto que nenhum de n&oacute;s tinha feito algo  deste g&eacute;nero antes mas, de facto, tem valido a pena. Estamos a divertir-nos  juntos e encontr&aacute;mos de novo o amor verdadeiramente. Toda a gente devia  experimentar! ...\"<span> Sr. M e Sr.&ordf; B - Junho 2007.</span></div>" +
                             "<div>\"... Muito obrigada por me ajudarem a encontrar o meu parceiro.  Somos t&atilde;o perfeitos um para o outro - s&oacute; tenho pena que n&atilde;o nos tenhamos  conhecido mais cedo! Estive solteira durante 5 anos mas foram apenas necess&aacute;rio  3 meses ap&oacute;s me inscrever no TopMatch! ...\"<span> Sr.&ordf; S. - Maio 2007.</span></div>" +
                             "<div>\"... Fiquei chocado com a genuinidade das pessoas que conheci nas  Apresenta&ccedil;&otilde;es. A princ&iacute;pio estava c&eacute;ptico, mas isto de facto abriu-me os olhos.  Conheci pessoas amorosas e tenho estado agora a encontrar-me com uma senhora h&aacute;  5 meses - fa&ccedil;am figas! ...\"<span> Sr. F. - Maio 2007.</span></div>" +
                             "<div>\"... Estive solteiro durante 3 anos at&eacute; que um amigo meu come&ccedil;ou a  forma&ccedil;&atilde;o como Consultor de MatchMaking do TopMatch e me convenceu a sair da  minha resigna&ccedil;&atilde;o e a fazer algo positivo para conhecer algu&eacute;m! Decidi  inscrever-me no TopMatch e conheci o amor da minha vida. Obrigado TopMatch! ...\"<span>  Sr. P. - Abril 2007.</span></div>" +
                             "<div>\"... &Eacute; t&atilde;o simples, &eacute; s&oacute; preencher um formul&aacute;rio de consulta e  esperar que sejam enviadas para o endere&ccedil;o de e-mail as sugest&otilde;es para um  parceiro compat&iacute;vel! ...\"<span> Sr.&ordf; P. - Janeiro 2007.</span></div>" +
                             "<div>\"... Tentei os encontros online, mas &eacute; um aut&ecirc;ntico campo de minas  - fotos desactualizadas ou mesmo falsas, idades incorrectas, pessoas casadas,  que confus&atilde;o! O servi&ccedil;o TopMatch faz muito mais sentido! ...\"<span> Sr. D. - Janeiro  2007.</span></div>" +
                             "<div>\"... Quis escrever-vos para dizer como estou  satisfeita com o servi&ccedil;o prestado pela vossa empresa. Recomendaria a todas as  pessoas solteiras que se inscrevessem e j&aacute; o fiz a muitos dos meus amigos! ...\"<span>  Sr.&ordf; B. - Janeiro 2007.</span></div>";
     var commentsscroll = new scrollObject("member_comments_scroll", 160, 200, "up", 12000, 1.01);
     commentsscroll.scroll();
   }
   if(occupationsdiv != null) {   // **************************** 3. Member Occupations:
     occupationsdiv.innerHTML = "<div><span>Profissionais de todas as &Aacute;reas, Directores de Empresas, M&eacute;dicos . . .</span></div>" +
                                "<div><span>Professores, Profissionais de Cuidados de Sa&uacute;de, Empres&aacute;rios . . .</span></div>" +
                                "<div><span>Directores de Vendas, Trabalhadores por Conta Pr&oacute;pria . . .</span></div>" +
                                "<div><span>Contabilistas, Executivos, Gestores de Recursos Humanos, Advogados . . .</span></div>" +
                                "<div><span>Banqueiros, Consultores Financeiros, Consultores de Inform&aacute;tica . . .</span></div>";
     var occupationsscroll = new scrollObject("occupations_scroll", 390, 20, "left", 6000, 1.11);
     occupationsscroll.scroll();
   }
   if(gallerydiv != null) {   // **************************** 4. Member Gallery:

     if(gallerydiv.innerHTML.length > 100) { // data is already added from included php file
         galleryscroll = new scrollObject("member_gallery", 380, 580, "up", 8000, 1.11);
         galleryscroll.scroll();
     } else {
        LoadMemberGallery();   // call function to load data
     }
   }
   if(tmofferdiv != null) {
      OpenTMOffer();
   }

   if(locationsdiv != null) {    // **************************** 6. Add the owner message
         var text = locationsdiv.innerHTML;
         var sitetitle = document.title.split(' : ');
         var areaname = sitetitle[0];
         var siteaddress = location.hostname.replace('www.','');
         urlPeaces = siteaddress.split('.');
         if(urlPeaces[0].substr(0,8)==='topmatch') { // Website is Country website
               country = 'International';
         } else {
               countryURL = urlPeaces[1];
               switch(countryURL){
                     case 'topmatch-uk':
                           country = 'UK';
                     break;
                     case 'topmatch-canada':
                           country = 'Canada';
                     break;
                     case 'topmatch':
                           country = 'Ireland';
                     break;
                     case 'topmatch-usa':
                           country = 'USA';
                     break;
                     case 'topmatch-portugal':
                           country = 'Portugal';
                     break;
                     default: country='International.'
               }
         }
         text = text.replace('TopMatch International Locations:','');
         locationsdiv.innerHTML= areaname +" is an independently owned Franchise of TopMatch " +country +' '+ text;
   }


}



function SelectGalleryPerson(refno) {
   var refnumber=refno.slice(2);
   var allreferences=document.getElementById('gallery_references').value;
   var choosen_ref_count=Math.round(document.getElementById('choosen_ref_count').value);
   var background='url(http://www.topmatch-uk.com/[img]/transparent.gif)';
   if(allreferences.search(refnumber) >= 0) {
      allreferences=allreferences.replace(refnumber+", ", "");
      choosen_ref_count=choosen_ref_count-1;
   } else {
      if(choosen_ref_count<3) {
         allreferences=allreferences+refnumber+"\, ";
         background='url(http://www.topmatch-uk.com/[img]/gallery_choosen.jpg) no-repeat 265px 0px';
         choosen_ref_count=choosen_ref_count+1;
      } else { 
         alert("You have already chosen 3 members from the gallery!\nNo further selections are allowed.");
      }
   }
document.getElementById('choosen_ref_count').value=choosen_ref_count;
document.getElementById('gallery_references').value=allreferences;
document.getElementById(refno).style.background=background;
}

/* ********************************************************************
* HTML Block Scroller & Marquee JavaScript - v2.0
*  - Copyright 2008 - Licenced for free distribution under the BSDL
*  -     http://www.opensource.org/licenses/bsd-license.php
*
* Have one or more scrolling blocks of HTML anywhere on your webpages.
* The scroller will even pause on mouseover and resume on mouseout.
*
* Version 2.0
*   - Uses DOM-only methods (compatible with application/xhtml+xml)
*   - Blocks are created in the HTML page, rather than as JS variables
*   - Automatic startup on page load

***********************************************************************
*** Instructions ******************************************************
***********************************************************************
* 1. Create the container for the scroller in the body of your HTML:
*
* <div id="scr1"></div>
*
* Where "scr1" is any name you choose.  You don't have to use a <div>
* either.  You may use any block level element that can be pixel
* resized; such as a <span> element to which the display:block; CSS
* property has been applied.
*
***********************************************************************
* 2. Fill the scroller container with child <div> blocks:
*
* <div id="scr1">
*   <div class="default">
*     The first block of the scroller.
*     The contents of this block will be displayed if the browser does
*     not support the scroller.
*   </div>
*   <div>Block 2</div>
*   <div>Block 3</div>
*
*   ...
*
* </div>
*
* Assign the class "default" to the first block, the one which you
* would like displayed if javascript is disabled.
*
***********************************************************************
* 3. Add the following rule(s) to your CSS stylesheet:
*
* #scr1 div {
*  visibility:hidden;
* }
* #scr1, #scr1 div.default {
*   width:160px;
*   height:120px;
*   overflow:hidden;
*   visibility:visible;
* }
* #scr1 table tr td div {
*  visibility:visible;
* }
*
* Change both "scr1" to the id you gave to the scroller container.  The
* width and height properties should match those you will use in step 4.
*
* To further style the scroller container, assign CSS properties to the
* scroller target id:
*
* #scr1 {
*   background-color:#f6f6f6;
*   margin:0px auto;
* }
*
* The script will replace each block you add to the container with a
* single-celled <table>. So to style the blocks of your scroller, you
* can style these table cells as if they were actually part of your
* document source:
*
* #scr1 table tr td {
*   padding:10px;
*   color:#ff0000;
*   text-align:center;
*   vertical-align:middle;
* }
*
***********************************************************************
* 4. Create a new scrollObject:
*
* new scrollObject("scr1", 120, 120, "up", 5000, 1.4);
*
* The arguments for this object are as follows:
*  a. - ID of the target tag (from step 1)
*  b. - Width (in pixels) of your scroller
*  c. - Height (in pixels) of your scroller
*  d. - Scroll direction: one of "up", "down", "left" or "right"
*  e. - Amount of time to pause before next scroll begins (ms)
*  f. - Slide-in speed of your scroller (1.001 up to width or height)
*
***********************************************************************
*** To add more scrollers to the same page: ***************************
***********************************************************************
* 1. Create additional containers - with different ID's - and blocks in
*    the body of your HTML
*
* <div id="scr2">
*   <div class="default"><strong>HTML is allowed too!</strong></div>
*   <div><img src="/images/mybanner.jpg" alt=""></div>
*   <div><a href="/home">And links!</a></div>
*   <div>As long as it fits within the dimensions above</div>
* </div>
*
* <div id="scr3">
*   <div class="default">Block 1</div>
*   <div>Block 2</div>
*   <div>Block 3</div>
*   <div>Block 4</div>
* </div>
*
***********************************************************************
* 2. Add the matching rules to your CSS stylesheet
*
* #scr2 div,
* #scr3 div {
*  visibility:hidden;
* }
* #scr2, #scr2 div.default {
*   width:468px;
*   height:60px;
*   overflow:hidden;
*   visibility:visible;
* }
* #scr3, #scr3 div.default {
*   width:140px;
*   height:140px;
*   overflow:hidden;
*   visibility:visible;
* }
* #scr2 table tr td div,
* #scr3 table tr td div {
*  visibility:visible;
* }
*
***********************************************************************
* 3. Create new scrollObjects for each scroller in the <script> tag:
*
* new scrollObject("scr2", 468, 60, "down", 10000, 1.2);
* new scrollObject("scr3", 140, 140, "right", 4000, 2);
*
***********************************************************************
*** End Instructions **************************************************
*************************************************** BEGIN CODE ***** */


/* ********************************************************************
 * The Mighty ScrollObject
 *   - Don't edit this if you know what's good for ya!
 *
 */
function scrollObject(main, width, height, direct, pause, speed) {
  var self = this;
  this.main = main;
  this.width = width;
  this.height = height;
  this.direct = direct;
  this.pause = pause;
  this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
  this.slope = (direct == "up" || direct == "left") ? 1 : -1;
  this.prev = this.offset = 0;
  this.curr = 1;
  this.mouse = false;
  this.scroll = function() {
    this.main = document.getElementById(this.main);
    this.main.style.overflow = "hidden";
    this.main.style.position = "relative";
    this.main.style.width = this.width + "px";
    this.main.style.height = this.height + "px";
    var b = [], c;
    while (this.main.firstChild) if ((c = this.main.removeChild(this.main.firstChild)).nodeName == "DIV") b.push(c);
    for (var x = 0; x < b.length; x++) {
      var table = document.createElement('table');
          table.cellPadding = table.cellSpacing = table.border = "0";
          table.style.position = "absolute";
          table.style.left = table.style.top = "0px";
          table.style.width = table.style.height = "100%";
          table.style.overflow = table.style.visibility = "hidden";
        var tbody = document.createElement('tbody');
          var tr = document.createElement('tr');
            var td = document.createElement('td');
              while (b[x].firstChild)
                  td.appendChild(b[x].removeChild(b[x].firstChild));
              tr.appendChild(td);
            tbody.appendChild(tr);
          table.appendChild(tbody);
      this.main.appendChild(table);
    } b = c = null;
    if (this.main.childNodes.length > 1) {
      this.main.onmouseover = function() { self.mouse = true; };
      this.main.onmouseout = function() { self.mouse = false; };
      setInterval(function() {
        if (!self.offset && self.scrollLoop()) self.main.childNodes[self.curr].style.visibility = "visible";
      }, this.pause);
    } this.main.childNodes[this.prev].style.visibility = "visible";
  };
  this.scrollLoop = function() {
    if (!this.offset) {
      if (this.mouse) return false;
      this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
    } else this.offset = Math.floor(this.offset / this.speed);
    if (this.direct == "up" || this.direct == "down") {
      this.main.childNodes[this.curr].style.top = (this.offset * this.slope) + "px";
      this.main.childNodes[this.prev].style.top = ((this.offset - this.height) * this.slope) + "px";
    } else {
      this.main.childNodes[this.curr].style.left = (this.offset * this.slope) + "px";
      this.main.childNodes[this.prev].style.left = ((this.offset - this.width) * this.slope) + "px";
    }
    if (!this.offset) {
      this.main.childNodes[this.prev].style.visibility = "hidden";
      this.prev = this.curr;
      if (++this.curr >= this.main.childNodes.length) this.curr = 0;
    } else setTimeout(function() { self.scrollLoop(); }, 30);
    return true;
  };

}

  if (window.addEventListener) {
    window.addEventListener('load', AddContentANDScroll, false); 
  } else if (window.attachEvent)
    window.attachEvent('onload', AddContentANDScroll);


// **************** TM Offer functions
var t2

function OpenTMOffer() {
var bottomvalue = document.getElementById("tmoffer").style.bottom;
if(bottomvalue){var b=bottomvalue;} else {b=(screen.height*2)+"px";}
b = Math.ceil(b.replace(/px/,''));
if(b>100){b=b-10;} else{b=b-1;}
if (b>=60) {
document.getElementById("tmoffer").style.bottom=b+"px";
t2=setTimeout("OpenTMOffer()",10);
}
}

function HideTMOffer(){
document.getElementById("tmoffer").style.display="none";
}
// **************** END TMOffer Functions





var xmlHttp

function LoadMemberGallery() {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!\nMember Gallery cannot be displayed.");
  return;
  } 
var url="./[incl]/member-online-gallery.php";
url=url+"?sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

} 

function stateChanged() { 
   if (xmlHttp.readyState==4){
       gallerydiv = document.getElementById('member_gallery');
       gallerydiv.innerHTML = xmlHttp.responseText; 
       galleryscroll = new scrollObject("member_gallery", 380, 580, "up", 8000, 1.11);
       galleryscroll.scroll();
   } 
}

function GetXmlHttpObject() {
var xmlHttp=null;
try   {   // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest(); }
catch (e) {   // Internet Explorer
  try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
}
return xmlHttp;
}
